package com.zp.qualitypractice.mvp3;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;
import com.zp.qualitypractice.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by izp on 2017/7/2.
 */

public class TestActivity  extends RxAppCompatActivity implements ExpressView{
    @BindView(R.id.tv_result)
    TextView tvPostInfo;

    private ProgressDialog progressDialog;
    private ExpressPresenter expressPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        ButterKnife.bind(this);

        expressPresenter = new ExpressPresenter(this, this);
        progressDialog = new ProgressDialog(this);
        progressDialog.setMessage("正在获取快递信息...");
    }

    @OnClick(R.id.btn_action)
    public void onViewClicked() {
        expressPresenter.getExpressInfo("yuantong", "11111111111");
    }

    @Override
    public void updateView(ExpressInfo expressInfo) {
        tvPostInfo.setText(expressInfo.toString());
    }

    @Override
    public void showProgressDialog() {
        progressDialog.show();
    }

    @Override
    public void hideProgressDialog() {
        progressDialog.hide();
    }

    @Override
    public void showError(String msg) {
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }
}
